<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport"
		content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link rel="stylesheet" href="__CSS__/ex/common.css">
	<link rel="stylesheet" href="__CSS__/ex/login.css">
	<title>WESTGOLDB.EXC</title>
    <script src="__JS__/ios-web-app.js"></script>
</head>

<body style="padding-top: 38px">
<div class="login" style="background: #1A68B3;">
		<div class="header">
			<div class="header_left"><a href="{:U('Public/login')}"><img src="__IMG__/ex/back.png" alt=""></a></div>
			<p>Forget Password</p>
			<div class="header_right"></div>
		</div>
		<div class="loginform register">
			<div class="form_content username">
				<img src="__IMG__/ex/user.png" alt="">
				<div class="line"></div>
				<input type="text" placeholder="Account Number" id="username">
			</div>
			<!--<div class="form_content username">-->
				<!--<img src="__IMG__/ex/user.png" alt="">-->
				<!--<div class="line"></div>-->
				<!--<input type="text" placeholder="请输入注册的手机号" id="phone">-->
			<!--</div>-->
			<!--<div class="form_content username">-->
				<!--<img src="__IMG__/ex/pwd.png" alt="">-->
				<!--<div class="line"></div>-->
				<!--<input type="number" name="code2" class="input-1 code" id="code" placeholder="请输入验证码" style="width: 50%" />-->
				<!--<div class="line"></div>-->
				<!--<div class="getCode get-code" style="color: white;width: 40%;text-align: center" id="getCode">获取验证码</div>-->
			<!--</div>-->

			<div class="form_content username">
				<img src="__IMG__/ex/user.png" alt="">
				<div class="line"></div>
				<input type="text" placeholder="Email" id="email">
			</div>
			<div class="form_content username">
				<img src="__IMG__/ex/pwd.png" alt="">
				<div class="line"></div>
				<input type="number" name="code2" class="input-1 code" id="code1" placeholder="Verification Code" style="width: 50%" />
				<div class="line"></div>
				<div class="getCode1 get-code" style="color: white;width: 40%;text-align: center" id="getCode1">Get Code</div>
			</div>

			<div class="form_content username">
					<img src="__IMG__/ex/user.png" alt="">
					<div class="line"></div>
					<input type="text" placeholder="Login Password" id="password">
			</div>
			<div class="form_content username">
					<img src="__IMG__/ex/user.png" alt="">
					<div class="line"></div>
					<input type="text" placeholder="Re Login Password" id="password_re">
			</div>
			<div class="form_content username">
				<img src="__IMG__/ex/user.png" alt="">
				<div class="line"></div>
				<input type="text" placeholder="New Payment Password" id="password2">
			</div>
			<div class="form_content username">
				<img src="__IMG__/ex/user.png" alt="">
				<div class="line"></div>
				<input type="text" placeholder="Re Payment Password" id="password2_re">
			</div>
			<div class="btn login_btn lsub" id="sub">Submit</div>
		</div>
	</div>

	<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
	<script>
			$(function() {
				// $(document).on('click','#getCode',function(){
				$("#getCode").on('click', function () {
					var num = 59;
					var that = $(this);
					var phone = $('#phone').val();
					if (phone == '') {
						alert('Please enter the registered mobile phone number');
					} else if (!(/^1[34578]\d{9}$/.test(phone))) {
						alert('Incorrect format of mobile phone number');
					} else {
						// var timer = setInterval(function () {
						// 	that.attr('id', '');
						// 	that.text(num + 's');
						// 	that.addClass('active');
						// 	num--;
						// 	if (num == 0) {
						// 		that.attr('id', 'getCode');
						// 		clearInterval(timer);
						// 		that.text('重新发送');
						// 	}
						// }, 1000);
						$.post("{:U('Public/sendCode2')}", {"phone": phone,"phone_ex":'86'}, function (data) {
							alert(data.message);
							console.log(data)
							var timer = setInterval(function () {
								that.attr('id', '');
								that.text(num + 's');
								that.addClass('active');
								num--;
								if (num == 0) {
									that.attr('id', 'getCode');
									clearInterval(timer);
									that.text('Resend');
								}
							}, 1000);
						})
					}
				});
				$("#getCode1").on('click', function () {
					var num = 60;
					var that = $(this);
					var email = $('#email').val();
					if (email == '') {
						alert('Please input email');
					}
					// else if (!(/^1[34578]\d{9}$/.test(phone))) {
					//     alert('手机号码格式不正确');
					// }
					else {
						// var timer = setInterval(function () {
						//     that.attr('id', '');
						//     that.text(num + 's');
						//     that.addClass('active');
						//     num--;
						//     if (num == 0) {
						//         that.attr('id', 'getCode');
						//         clearInterval(timer);
						//         that.text('重新发送');
						//     }
						// }, 1000);
						$.post("{:U('Public/send_email')}", {"email": email}, function (data) {
							alert(data.message);
							console.log(data)
							var timer = setInterval(function () {
								that.attr('id', '');
								that.text(num + 's');
								that.addClass('active');
								num--;
								if (num == 0) {
									that.attr('id', 'getCode1');
									clearInterval(timer);
									that.text('Resend');
								}
							}, 1000);
						})
					}
				});
				$('#sub').click(function(){
					$.ajax({
						type:"post",
						url:"{:U('Public/find_password')}",
						data:{
							// phone:$('#phone').val(),
							email:$('#email').val(),
							username:$('#username').val(),
							// code:$('#code').val(),
							code:$('#code1').val(),
							password:$('#password').val(),
							password_re:$('#password_re').val(),
							password2:$('#password2').val(),
							password2_re:$('#password2_re').val(),
						},
						dataType:"json",
						success:function(data){
							if(data.code==1){
								alert(data.msg);
                                window.location.href=data.data;
							}else{
								alert(data.msg);
							}
						}
					});
				});
			})
		</script>
</body>

</html>